package org.jetty;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

/**
 * Jetty入口文件
 * http://blog.csdn.net/robinpipi/article/details/7557035
 * @author Nick
 */
public class Application {

	public static void main(String[] args) {

		int port = 8081;
		Server server = new Server(port);
		WebAppContext webAppContext = new WebAppContext("webapp", "/");

		webAppContext.setDescriptor("webapp/WEB-INF/web.xml");
		webAppContext.setResourceBase("src/main/webapp");
		webAppContext.setDisplayName("Jetty");
		webAppContext.setClassLoader(Thread.currentThread().getContextClassLoader());
		webAppContext.setConfigurationDiscovered(true);
		webAppContext.setParentLoaderPriority(true);
		
		// 测试nginx 主机ip
		webAppContext.setWelcomeFiles(new String[]{"/1.jsp"});
		

		try {
			server.setHandler(webAppContext);
			server.start();
			System.out.println("server is  start, port is " + port + "............");
			server.join();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}